/*   1:    */ package org.intellij.plugins.relaxNG.compact.formatting;
/*   2:    */ 
/*   3:    */

import com.intellij.formatting.*;
import com.intellij.lang.ASTNode;
import com.intellij.openapi.util.TextRange;
import com.intellij.psi.PsiElement;
import org.intellij.plugins.relaxNG.compact.RncElementTypes;
import org.intellij.plugins.relaxNG.compact.RncTokenTypes;
import org.intellij.plugins.relaxNG.compact.psi.RncDecl;
import org.intellij.plugins.relaxNG.compact.psi.RncDefine;
import org.intellij.plugins.relaxNG.compact.psi.RncFile;
import org.intellij.plugins.relaxNG.compact.psi.RncGrammar;
import org.intellij.plugins.relaxNG.compact.psi.impl.RncDocument;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

import java.util.ArrayList;
import java.util.List;

/*   4:    */
/*   5:    */
/*   6:    */
/*   7:    */
/*   8:    */
/*   9:    */
/*  10:    */
/*  11:    */
/*  12:    */
/*  13:    */
/*  14:    */
/*  15:    */
/*  16:    */
/*  17:    */
/*  18:    */
/*  19:    */
/*  20:    */
/*  21:    */
/*  22:    */
/*  23:    */
/*  24:    */ 
/*  25:    */ class RncBlock
/*  26:    */   implements Block
/*  27:    */ {
/*  28:    */   private final ASTNode a;
/*  29:    */   
/*  30:    */   public RncBlock(ASTNode paramASTNode)
/*  31:    */   {
/*  32: 40 */     this.a = paramASTNode;
/*  33:    */   }
/*  34:    */   
/*  35:    */   @NotNull
/*  36:    */   public TextRange getTextRange()
/*  37:    */   {
/*  38: 45 */     TextRange tmp9_4 = this.a.getTextRange();
/*  39: 45 */     if (tmp9_4 == null) {
/*  40: 45 */       throw new IllegalStateException(String.format("@NotNull method %s.%s must not return null", new Object[] { "org/intellij/plugins/relaxNG/compact/formatting/RncBlock", "getTextRange" }));
/*  41:    */     }
/*  42: 45 */     return tmp9_4;
/*  43:    */   }
/*  44:    */   
/*  45:    */   @NotNull
/*  46:    */   public List<Block> getSubBlocks()
/*  47:    */   {
/*  48: 50 */     ArrayList localArrayList = new ArrayList();
/*  49: 51 */     ASTNode localASTNode = this.a.getFirstChildNode();
/*  50: 52 */     while (localASTNode != null)
/*  51:    */     {
/*  52: 53 */       if ((!RncTokenTypes.WHITESPACE.contains(localASTNode.getElementType())) && (localASTNode.getTextLength() > 0)) {
/*  53: 54 */         localArrayList.add(new RncBlock(localASTNode));
/*  54:    */       }
/*  55: 56 */       localASTNode = localASTNode.getTreeNext();
/*  56:    */     }
/*  57: 58 */     ArrayList tmp72_71 = localArrayList;
/*  58: 58 */     if (tmp72_71 == null) {
/*  59: 58 */       throw new IllegalStateException(String.format("@NotNull method %s.%s must not return null", new Object[] { "org/intellij/plugins/relaxNG/compact/formatting/RncBlock", "getSubBlocks" }));
/*  60:    */     }
/*  61: 58 */     return tmp72_71;
/*  62:    */   }
/*  63:    */   
/*  64:    */   @Nullable
/*  65:    */   public Wrap getWrap()
/*  66:    */   {
/*  67: 64 */     return null;
/*  68:    */   }
/*  69:    */   
/*  70:    */   @Nullable
/*  71:    */   public Indent getIndent()
/*  72:    */   {
/*  73: 69 */     if (a()) {
/*  74: 70 */       return Indent.getAbsoluteNoneIndent();
/*  75:    */     }
/*  76: 71 */     if (((this.a.getTreeParent().getPsi() instanceof RncGrammar)) && (!RncTokenTypes.BRACES.contains(this.a.getElementType()))) {
/*  77: 73 */       return Indent.getNormalIndent();
/*  78:    */     }
/*  79: 75 */     return null;
/*  80:    */   }
/*  81:    */   
/*  82:    */   private boolean a()
/*  83:    */   {
/*  84: 79 */     PsiElement localPsiElement = this.a.getTreeParent().getPsi();
/*  85: 80 */     return ((localPsiElement instanceof RncDocument)) || ((localPsiElement instanceof RncFile)) || (((localPsiElement instanceof RncGrammar)) && ((localPsiElement.getParent() instanceof RncDocument)));
/*  86:    */   }
/*  87:    */   
/*  88:    */   @Nullable
/*  89:    */   public Alignment getAlignment()
/*  90:    */   {
/*  91: 88 */     return null;
/*  92:    */   }
/*  93:    */   
/*  94:    */   @Nullable
/*  95:    */   public Spacing getSpacing(Block paramBlock1, @NotNull Block paramBlock2)
/*  96:    */   {
/*  97: 93 */     if (paramBlock2 == null) {
/*  98: 93 */       throw new IllegalArgumentException(String.format("Argument %s for @NotNull parameter of %s.%s must not be null", new Object[] { "1", "org/intellij/plugins/relaxNG/compact/formatting/RncBlock", "getSpacing" }));
/*  99:    */     }
/* 100: 93 */     if (paramBlock1 == null) {
/* 101: 94 */       return null;
/* 102:    */     }
/* 103: 96 */     ASTNode localASTNode = ((RncBlock)paramBlock1).a;
/* 104: 97 */     PsiElement localPsiElement1 = localASTNode.getPsi();
/* 105: 98 */     PsiElement localPsiElement2 = ((RncBlock)paramBlock2).a.getPsi();
/* 106:100 */     if (((localPsiElement1 instanceof RncDecl)) && ((localPsiElement2 instanceof RncDecl))) {
/* 107:101 */       return b();
/* 108:    */     }
/* 109:103 */     if ((((localPsiElement1 instanceof RncDecl)) || ((localPsiElement1 instanceof RncDefine)) || (localASTNode.getElementType() == RncElementTypes.START)) && (((localPsiElement2 instanceof RncDefine)) || ((localPsiElement2 instanceof RncGrammar)))) {
/* 110:107 */       return b();
/* 111:    */     }
/* 112:109 */     return null;
/* 113:    */   }
/* 114:    */   
/* 115:    */   private static Spacing b()
/* 116:    */   {
/* 117:113 */     return Spacing.createSpacing(0, 2147483647, 1, true, 100);
/* 118:    */   }
/* 119:    */   
/* 120:    */   @NotNull
/* 121:    */   public ChildAttributes getChildAttributes(int paramInt)
/* 122:    */   {
/* 123:118 */     void tmp9_6 = new ChildAttributes(null, null);
/* 124:118 */     if (tmp9_6 == null) {
/* 125:118 */       throw new IllegalStateException(String.format("@NotNull method %s.%s must not return null", new Object[] { "org/intellij/plugins/relaxNG/compact/formatting/RncBlock", "getChildAttributes" }));
/* 126:    */     }
/* 127:118 */     return tmp9_6;
/* 128:    */   }
/* 129:    */   
/* 130:    */   public boolean isIncomplete()
/* 131:    */   {
/* 132:123 */     return false;
/* 133:    */   }
/* 134:    */   
/* 135:    */   public boolean isLeaf()
/* 136:    */   {
/* 137:128 */     return false;
/* 138:    */   }
/* 139:    */ }



/* Location:           E:\idea\

 * Qualified Name:     org.intellij.plugins.relaxNG.compact.formatting.RncBlock

 * JD-Core Version:    0.7.0.1

 */